import { type Decorator, type StoryContext } from '@storybook/vue3';
import { createApp, h } from 'vue';
import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css';

export const withElementPlus: Decorator = (story, context: StoryContext) => {
    return {
        setup() {
            const storyComponent = story();
            return () => h(storyComponent);
        },
        mounted() {
            const app = createApp(this);
            app.use(ElementPlus);
            app.mount(this.$el);
        },
        template: '<div ref="root"></div>',
    };
};
